package com.op.studyingliteapp.database.table;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.op.studyingliteapp.BuildConfig;

/**
 * @author handsome
 * @version 创建时间：2015年7月25日 下午8:09:30 类说明
 */
public class CourseTable implements BaseColumn {

	private static final String TAG = CourseTable.class.getSimpleName();

	// Course table
	public static final String TABLE_COURSE = "course";
	public static final String COLUMN_NAME = "name";
	public static final String COLUMN_CREDIT = "credit";
	public static final String COLUMN_PERIOD = "period";
	public static final String COLUMN_USER_ID = "userId";
	public static final String COLUMN_DEPT_ID = "deptId";
	public static final String COLUMN_ICON_URL = "iconUrl";

	public static final String[] PROJECTION = { COLUMN_ID, COLUMN_NAME, COLUMN_CREDIT, COLUMN_PERIOD, COLUMN_DEPT_ID, COLUMN_USER_ID, COLUMN_CREATE_TIME, COLUMN_UPDATE_TIME, COLUMN_ICON_URL };

	// Table creation SQL statement
	private static final String CREATE_TABLE = "create table " + TABLE_COURSE + "(" + COLUMN_ID + " text primary key, " + COLUMN_NAME + " text, " + COLUMN_CREDIT + " text, " + COLUMN_PERIOD + " text, " + COLUMN_DEPT_ID + " text, " + COLUMN_USER_ID + " text, " + COLUMN_CREATE_TIME + " text, "
			+ COLUMN_UPDATE_TIME + " text, " + COLUMN_ICON_URL + " text" + ");";

	public static void onCreate(SQLiteDatabase db) {
		if (BuildConfig.DEBUG) {
			Log.i(TAG, "Creating course table");
		}
		db.execSQL(CREATE_TABLE);
	}

	public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if (BuildConfig.DEBUG) {
			Log.i(TAG, "Upgrading course table");
		}
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_COURSE);
		onCreate(db);
	}
}
